<?php
	include "includes".DIRECTORY_SEPARATOR."start_session.php";
	include "javascript".DIRECTORY_SEPARATOR."serverside.php";
	if ( !defined('USERNAME') || !defined('GROUP') || !defined ('MAIL') )
	{
		header("Location: manage_login.php");
		exit;
	}
	
	$var_user = MAIL;
	
	$query_furnizori = mysqli_query($dbc, "SELECT `CUI_CF`, `cod_judet`, `numar_decizie_autorizare`, `data_decizie_autorizare`, `nume`, `regiune`, `judet`, `localitate`, `localizare`, `strada`, `nr_strada`, `bloc`, `scara`, `etaj`, `apartament`, `telefon`, `fax`, `email`, `website`, `forma_organizare`, `forma_proprietate`, `smac`, `email_user_comisie`, `state_anc` FROM `furnizor` WHERE `state_anc`='neaprobat_anc'");

	$query_programe = mysqli_query($dbc, "SELECT `nume_program`, `id_furnizori_programe`, `CUI_CF`, `cod`, `serie_autorizatie`, `nr_autorizatie_program`, `data_autorizatie_program`, `tip_program`, `SO_SPP`, `oferta_ucenicie`, `stare_program`, `nr_decizie_respingere`, `data_decizie_respingere`, `motiv_respingere`, `nr_duplicat_autorizatie`, `data_duplicat_autorizatie`, `nr_retragere_autorizatie`, `data_retragere_autorizatie`, `motiv_retragere_autorizatie`, `state_anc` FROM `furnizori_programe` WHERE `state_anc`='neaprobat_anc'");
	
	 $query_sesiuni = mysqli_query($dbc, "SELECT `id_sesiune`, `id_furnizori_programe`, `data_sesiunii`, `desfasurat_in_alt_judet`, `nr_persoane_inscrise`, `nr_persoane_finalizat`, `nr_participanti_absolvire`, `nr_absolventi_barbati_sub_25`, `nr_absolventi_barbati_peste_25`, `nr_asolventi_femei_sub_25`, `nr_absolventi_femei_peste_25`, `nr_absolventi_alte_sesiuni`, `observatii`, `state_anc` FROM `sesiuni` WHERE `state_anc`='neaprobat_anc'");
	
	echo "<br />";
	
	
	echo "<thead>";
		echo "<tr>";
			echo "<th scope=\"col\"></th>";
				echo "<th scope=\"col\">";
				echo "</th>";
			echo "</tr>";
	echo "</thead>";
	echo "<tbody>";
		
		
	if($query_furnizori)
	{
		while($results_furnizori = mysqli_fetch_assoc($query_furnizori))
		{
			if (isUserEmailJudet($var_user, $results_furnizori['judet'] ))
			{
			echo"<tr>";
				echo"<td>";
					echo "<b>Furnizori</b>";
				echo"</td>";
				echo"<td>";
					echo "<b>".$results_furnizori["nume"]."</b>";
				echo"</td>";				
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?cui_furnizor=".$results_furnizori["CUI_CF"]."&view_furnizor=true\">Vizualizare</a>";
				echo"</td>";
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?aprobare_furnizor=true&cui_furnizor=".$results_furnizori["CUI_CF"]."\">Aprobare</a>";
				echo"</td>";
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?aprobare_furnizor=false&cui_furnizor=".$results_furnizori["CUI_CF"]."\">Respingere</a>";
				echo"</td>";						
			echo"</tr>";
			}
		}	
	}

	if($query_programe)
	{
		while($results_programe = mysqli_fetch_assoc($query_programe))
		{
		   if (isUserEmailJudet($var_user, getProgramJudet($results_programe['CUI_CF']) ))
		   {
			echo"<tr>";
				echo"<td>";
					echo "<b>Programe</b>";
				echo"</td>";
				echo"<td>";
				echo "<b>".$results_programe['nume_program']."</b>";
				echo"</td>";
				echo"<td>";
						echo "<a href=\"user_anc_list_notifications.php?cui_furnizor=".$results_programe['CUI_CF']."&id_program=".$results_programe['id_furnizori_programe']."&view_program=true\">Vizualizare</a>";
				echo"</td>";
				echo"<td>";
						echo "<a href=\"user_anc_list_notifications.php?aprobare_program=true&cui_furnizor=".$results_programe['CUI_CF']."&id_program=".$results_programe['id_furnizori_programe']."\">Aprobare</a>";
				echo"</td>";
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?aprobare_program=false&cui_furnizor=".$results_programe['CUI_CF']."&id_program=".$results_programe['id_furnizori_programe']."\">Respingere</a>";
				echo"</td>";						
			echo"</tr>";
			}
		}	
	}
	
	if($query_sesiuni)
	{	
		//echo "merge1";
		while($results_sesiuni = mysqli_fetch_assoc($query_sesiuni))
		{
			if (isUserEmailJudet($var_user, getSessionJudet($results_sesiuni['id_furnizori_programe'])))
		    {
			echo"<tr>";
				echo"<td>";
					echo "<b>Sesiuni</b>";
				echo"</td>";
				echo"<td>";
					echo "<b>".$results_sesiuni['data_sesiunii']."</b>";
				echo"</td>";
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?id_sesiune=".$results_sesiuni['id_sesiune']."&id_program=".$results_sesiuni['id_furnizori_programe']."&view_sesiune=true\">Vizualizare</a>";
				echo"</td>";
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?aprobare_sesiune=true&id_sesiune=".$results_sesiuni['id_sesiune']."&id_program=".$results_sesiuni['id_furnizori_programe']."\">Aprobare</a>";
				echo"</td>";
				echo"<td>";
					echo "<a href=\"user_anc_list_notifications.php?aprobare_sesiune=false&id_sesiune=".$results_sesiuni['id_sesiune']."&id_program=".$results_sesiuni['id_furnizori_programe']."\">Respingere</a>";
				echo"</td>";						
			echo"</tr>";
			}
		}	
	}
	
	echo "</tbody>";
	
?>